<%@page contentType="text/html;charset=UTF-8"%>
<%@include file="../common.jsp"%>
<!DOCTYPE HTML>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<title>Project Infor</title>
	<link href="${ctx}/resources/css/project/project.css" rel="stylesheet">
	<link href="${ctx}/resources/font-awesome/css/font-awesome.min.css" rel="stylesheet">
	<link href="${ctx}/resources/css/bootstrap/bootstrap.min.css" rel="stylesheet">
	<script type="text/javascript" src="${ctx}/resources/js/highcharts/jquery-1.8.2.min.js"></script>
	<c:set var="active" value="variables"/>

</head>
<body>
	<div class="container">
		<div class="row">

		<div class="col-md-10">
			<div class="bs-callout help-callout">
				<p>				ReplicationContronller配置.				</p>
			</div>
			<form accept-charset="UTF-8" action="${ctx}/server/save" class="form-horizontal" id="edit" method="post">
				<div style="display:none">
				<input name="id" type="hidden" value="${server.id}">
				</div>
				<fieldset>
				<div class="form-group">
					<label class="control-label" for="serverName">名称</label>
					<div class="col-sm-10">
						<input class="form-control" id="serverName" name="serverName" required type="text" value="${controller.metadata.name}">
					</div>
				</div>
				<div class="form-group">
					<label class="control-label" for="node">Nodeds</label>
					<div class="col-sm-10">
						<!--input class="form-control" id="ip" name="ip" required type="text" value="${pod.spec.nodeName}"-->
						<select class="form-control" id="node" name="node">
							<c:forEach items="${nodes.items}" var="node" varStatus="nodeStatus">
						 	<option value="${node.metadata.name}">${node.metadata.name}</option>
							</c:forEach>
					     </select>
						<div class="light">Host：${pod.status.hostIP}(${pod.status.podIP})</div>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label" for="namespace">Namespaces</label>
					<div class="col-sm-10">
						<!--input class="form-control" id="port" name="port" type="text" value="${pod.metadata.namespace}"-->
						<select class="form-control" id="namespace" name="namespace">
							<c:forEach items="${namespaces.items}" var="ns" varStatus="nsStatus">
						 	<option value="${ns.metadata.name}">${ns.metadata.name}</option>
							</c:forEach>
					     </select>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label" for="ready">Ready</label>
					<div class="col-sm-10">
						<select class="form-control" id="ready" name="ready">
						 	<option value="True">True</option>
							<option value="False">False</option>
							<option value="Unknown">Unknown</option>
					     </select>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label" for="status">Status</label>
					<div class="col-sm-10">
						<select class="form-control" id="status" name="status">
						 	<option value="Pending">Pending</option>
							<option value="Running">Running</option>
							<option value="Succeeded">Succeeded</option>
							<option value="Failed">Failed</option>
							<option value="Unknown">Unknown</option>
					     </select>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label" for="description">labels</label>
					<div class="col-sm-10">
						<textarea class="form-control" id="description" name="description" rows="4">${pod.metadata.labels}</textarea>
					</div>
				</div>
				</fieldset>
				<fieldset>
					<div class="table-responsive">
						<table class="table table-striped table-hover">
							<thead>
							<tr>
								<th>#序号</th>
								<th>Name</th>
								<th>Image</th>
								<th>hostPort</th>
								<th>containerPort</th>			
								<th>protocol</th>
								<th>imagePullPolicy</th>
							</tr>
							</thead>
							<tbody>
							<c:forEach items="${pod.spec.containers}" var="container" varStatus="containerStatus">
								<tr>
									<td>${containerStatus.index + 1}</td>
									<td><span><a href="${ctx}/server/viewPod?namespace=${pod.metadata.namespace}&name=${pod.metadata.name}">${container.name}</a></span></td>
									<td>${container.image}</td>
									<td>${container.ports[0].hostPort}&nbsp;</td>
									<td>${container.ports[0].containerPort}&nbsp;</td>		
									<td>${container.ports[0].protocol}&nbsp;</td>
									<td><span class="label label-info">${container.imagePullPolicy}&nbsp;</span></td>
								</tr>
							</c:forEach>
							</tbody>
						</table>            
					  </div>
				</fieldset>
			
				<div class="form-actions">
					<input class="btn btn-save" name="commit" type="submit" value="Save changes">
					<a class="btn pull-right" href="${ctx}/server/list">Cancel</a>
				</div>
			</form>
		</div>
</div>
</div>
<script language="javascript">
	setStatus('${pod.status.phase}');
	setReady('${pod.status.conditions[0].status}');
	setNodes('${pod.spec.nodeName}');
	setNS('${controller.metadata.namespace}');
	
	function setStatus(status){
		$("#status").find("option[value='"+status+"']").attr("selected",true);
	}
	
	function setReady(type){
		$("#ready").find("option[value='"+type+"']").attr("selected",true);
	}
	
	function setNodes(node){
		$("#node").find("option[value='"+node+"']").attr("selected",true);
	}
	function setNS(ns){
		$("#namespace").find("option[value='"+ns+"']").attr("selected",true);
	}
</script>
</body>
</html>
